//
//  HMBaseTableViewController.m
//  SinaWeiBo
//
//  Created by WGP on 16/4/9.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "HMBaseTableViewController.h"
#import "HMVisitorView.h"
#import "HMHomeTableViewController.h"
#import "HMMessageTableViewController.h"
#import "HMDiscoverTableViewController.h"
#import "HMProfileTableViewController.h"
#import "HMNetWorkTool.h"
#import "HMOAuthViewController.h"
#import "HMUserAccountViewModel.h"

@interface HMBaseTableViewController ()

@end

@implementation HMBaseTableViewController

-(void)loadView
{
    if(![HMUserAccountViewModel sharedInstance].userLogin)
    {
        HMVisitorView *visitorView = [HMVisitorView visitorView];
        
        self.view = visitorView;
        visitorView.registrBtnBlock =
        ^{
            [self registerBarBtnItemDidClick];
        };
        
        visitorView.loginBtnBlock =
        ^{
            [self loginBarBtnItemDidClick];
        };
        
        self.view.backgroundColor = [UIColor colorWithWhite:237/255.0 alpha:1.0];
        if ([self isMemberOfClass:[HMHomeTableViewController class]]) {
            
        }
        else if ([self isMemberOfClass:[HMMessageTableViewController class]])
        {
            [visitorView changeVisitorWith:@"visitordiscover_image_message" message:@"登录后,别人评论你的微博,发给你的消息,都会在这里收到通知"];
        }
        else if ([self isMemberOfClass:[HMDiscoverTableViewController class]])
            
        {
            [visitorView changeVisitorWith:@"visitordiscover_image_message" message:@"登录后,最新,最热微博尽在掌握,不会再于时事潮流潮流檫肩而过"];
        }
        else if ([self isMemberOfClass:[HMProfileTableViewController class]])
        {
            [visitorView changeVisitorWith:@"visitordiscover_image_profile" message:@"登录后,你的微博,相册,个人资料会在这里显示,展示给别人"];
        }
        
        
    }else
    {
        [super loadView];
    }
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupNavBarItem];
}

-(void)setupNavBarItem
{
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(registerBarBtnItemDidClick)];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"登陆" style:UIBarButtonItemStylePlain target:self action:@selector(loginBarBtnItemDidClick)];
}

#pragma mark - 导航条item点击事件
-(void)registerBarBtnItemDidClick
{
    
}

-(void)loginBarBtnItemDidClick
{
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[HMOAuthViewController alloc] init]];
    
    [self presentViewController:nav animated:YES completion:nil];
}

@end










